<!DOCTYPE html>
<html lang="en">
<head>
	<{include file="user/header.html"}>
	<title>学员中心-德安信会计在线教育平台</title>
</head>
<body>
	<div class="wrap">
		<!--star left-->
		<div class="column">
			<{include file="user/left_menu.html"}>
		</div>
		<div id="ContMianBox">
			<!--star子栏目-->
			<div class="sub-colum">
				<div class="tit">班级管理</div>
				<ul>
					<li class="curr"><a href="/user/learn_card">我的学习卡</a></li>
					<li><a href="/user/learn_card/useing">激活学习卡</a></li>
				</ul>
			</div>
			<!--end子栏目-->
			<!--end left-->
			<div class="container narrow">
				<!--star conter-->
				<div class="cetContent">
					<div class="tit p-lr20">
						<span class="curr">我的学习卡</span>
						<span><a href="/user/learn_card/useing">激活学习卡</a></span>
					</div>
					<!--star内容区域-->
					<div class="mainScroll">
						<div class="mainContainer line-all">
							<!--star tabMainCont-->
							<fieldset class="layui-elem-field">
									<legend>筛选</legend>
									<div class="layui-field-box">
										<form class="layui-form layui-form-pane1" action="" method="post">
											<div class="layui-form-item">
												<div class="layui-inline">
													<div class="layui-input-inline" style="width: 200px;">
														<input type="text" name="title" placeholder="学习卡名称" autocomplete="off" class="layui-input" value="<{if !empty($conditions['title'])}><{$conditions['title']}><{/if}>">
													</div>
												</div>

												<div class="layui-inline">
													<div class="layui-input-inline" style="width: 200px;">
														<input type="text" name="card_num" placeholder="学习卡卡号" autocomplete="off" class="layui-input" value="<{if !empty($conditions['card_num'])}><{$conditions['card_num']}><{/if}>">
													</div>
												</div>

											</div>

											<div class="layui-form-item">

												<div class="layui-inline">
													<div class="layui-input-inline" style="width: 200px;">
														<input type="text" name="activation_time" placeholder="过期时间" autocomplete="off" class="layui-input" onclick="layui.laydate({elem: this, format: 'YYYY-MM-DD'})" value="<{if !empty($conditions['activation_time'])}><{$conditions['activation_time']|date_format: '%Y-%m-%d'}><{/if}>">
													</div>
												</div>
												<div class="layui-inline">
													<button type="submit" class="layui-btn">搜索</button>
												</div>
											</div>
										</form>
									</div>
								</fieldset>
							<!--商品列表 star-->
							<div class="goods_list p-t10">
									<div class="mtc_tab">
										<!--star mc-->
										<div class="mc">

											<table class="layui-table" lay-even lay-skin="row">
												<thead>
													<tr>
														<th>学习卡名称</th>
														<th>卡号</th>
														<th>售价</th>
														<th>激活时间</th>
														<th>有效天数</th>
														<th>过期时间</th>
														<th>操作</th>
													</tr>
												</thead>
												<tbody>
												<{foreach from=$card_list item=item}>
													<tr>
														<td class="center"><{$item['title']}></td>
														<td class="center"><{$item['card_num']}></td>
														<td class="center"><{$item['price']}></td>
														<td class="center"><{$item['activation_time']|date_format:'%Y-%m-%d'}></td>
														<td class="center">
															<{$item['expire_day']}>天
															<span style="color:red">
															<{if $time - ($item['activation_time']+$item['expire_day']*3600*24) >= 0}>
															(已过期)
															</span>
															<{else}>
															<span style="color:green">
															(剩余<{((($item['activation_time']+$item['expire_day']*3600*24)-$time)/(3600*24))|ceil}>天)
															</span>
															<{/if}>
															
														</td>
														<td class="center"><{($item['activation_time']+$item['expire_day']*3600*24)|date_format:'%Y-%m-%d'}></td>
														<td class="center">
															<a class="layui-btn layui-btn-primary layui-btn-small show_card" href="javascript:;" card_id="<{$item['id']}>" target="_blank">查看可用产品</a>
														</td>
													</tr>
												<{/foreach}>
												<{if $card_list|count eq 0}>
													<tr>
														<td class="center" style=" height:120px; text-align:center;line-height:120px;" colspan="8">
															赞无数据！
														</td>
													</tr>
												<{/if}>
												</tbody>
											</table>
											<div class="pages p-tb20" style="text-align:right;">
												<{$pagination}>
											</div>
										</div>
										<!--end mc-->
									</div>

								</div>
							<!--商品列表 end -->
						</div>
						<!--end tabMainCont-->
					</div>
				</div>
			</div>
			<!--end内容区域-->

		</div>
		<div id="score_box" style="padding: 10px; display: none;">
			<div class="layui-form-item">
				<div class="layui-inline">
					<input type="text" id="score" value="<{if !empty($conditions.name)}><{$conditions.name}><{/if}>" placeholder="分数" autocomplete="off" class="layui-input">
				</div>

				<div class="layui-inline">
					<textarea placeholder="评语" id="content" style="width: 340px;" class="layui-textarea"><{if isset($learn_what)}><{$learn_what}><{/if}></textarea>
				</div>
			</div>
			<div class="layui-form-item">
				<div class="layui-inline">
					<button type="submit" id="sub_score" class="layui-btn">确定</button>
				</div>
			</div>
		</div>
		<script>

		$(".score").click(function(){
			var _this = $(this);
			var teacher_id = $(this).attr("teacher_id");
			var class_id = $(this).attr("class_id");
			var index = layer.open({
				type: 1,
				resize: false,
				content: $('#score_box') //这里content是一个DOM，注意：最好该元素要存放在body最外层，否则可能被其它的相对元素所影响
			});
			// $("#score").val($(this).prev("span").html())

			$("#sub_score").click(function(){
				var score = $("#score").val();
				var content = $("#content").val();
				if(isNaN(score)){
					layer.msg("必须是数字！", {icon:5, anim: 6});
					return false;
				}
				if(score <= 0 || score > 100){
					layer.msg("评分必须大于1小于100", {icon:5, anim: 6});
					return false;
				}
				$.ajax({
					type: "POST",
					url: "/user/classes/update_score",
					dataType:"json",
					data:{'class_id':class_id, 'teacher_id':teacher_id, 'score':score, 'content':content},
					success: function(result){
						// layer.close(ii);
						if(result.error == 0){
							layer.close(index)
							layer.msg(result.msg, {icon:6});
							_this.text(result.msg);
							_this.prev("span").html(score);
							// _this.unbind("click");
						}else{
							layer.msg(result.msg, {icon:5});
						}
					}
				});
			})
		})
	</script>
	<script>
		layui.use('laydate', function(){
			var laydate = layui.laydate;

			var start = {
				min: '2016-11-31 23:59:59'
				,max: laydate.now(+1)
				,istoday: false
				,choose: function(datas){
				end.min = datas; //开始日选好后，重置结束日的最小日期
				end.start = datas //将结束日的初始值设定为开始日
				}
			};

			var end = {
				min: '2016-11-31 23:59:59'
				,max: laydate.now(+1)
				,istoday: false
				,choose: function(datas){
				  start.max = datas; //结束日选好后，重置开始日的最大日期
				}
			};

			document.getElementById('LAY_demorange_s').onclick = function(){
				start.elem = this;
				laydate(start);
			}
			document.getElementById('LAY_demorange_e').onclick = function(){
				end.elem = this
				laydate(end);
			}

		});
		$(".show_card").click(function(){
			var card_id = $(this).attr("card_id");
			if(card_id > 0){
				layer.open({
					type: 2,
					title: '可用产品',
					shadeClose: true,
					shade: 0.8,
					area: ['800px', '770px'],
					maxmin: true,
					content: '/user/learn_card/show_item/'+card_id //iframe的url
				}); 
			}
		})
	</script>
	</div>
</body>
</html>